home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 34 / Amiga Format CD34 (1998-11-20)(Future Publishing)(GB)[!][Christmas issue].iso / -seriously_amiga- / programming / c / viewperf5.1 / viewperf / mshf.c < prev    next >
C/C++ Source or Header  |  1998-10-01  |  5KB  |  176 lines

  1. #ifdef WIN32
  2. #include <windows.h>
  3. #endif
  4. #include <GL/gl.h>
  5. #include "vpDefine.h"
  6. #include "viewperf.h"
  7.  
  8. void FUNCTION(struct ThreadBlock *tb) 
  9. {
  10.   int meshnum,vertnum;
  11.   int numverts;
  12.   int meshcount = tb->np;
  13.   GLenum mode = tb->mode;
  14. #ifdef EXTERNAL
  15.   GLenum capability = tb->capability;
  16.   void (*lExternfunc)(GLenum) = tb->externfunc;
  17. #endif
  18.   struct mesh *pmsh=tb->msh;
  19.   struct vector *pvert;
  20.  
  21. #ifndef FUNCTION_CALLS
  22. #ifdef WIN32
  23.   void (APIENTRY *glVertex3fvP)(const GLfloat *);
  24. #else
  25.   void (*glVertex3fvP)(const GLfloat *);
  26. #endif
  27. #endif  
  28.  
  29. #if defined(FACET_NORM) || defined(VERT_NORM)
  30.   struct vector *pnorm;
  31. #ifndef FUNCTION_CALLS
  32. #ifdef WIN32
  33.   void (APIENTRY *glNormal3fvP)(const GLfloat *);
  34. #else
  35.   void (*glNormal3fvP)(const GLfloat *);
  36. #endif
  37. #endif /* ifndef FUNCTION_CALLS */
  38. #endif 
  39.  
  40. #if defined(FACET_COLOR) || defined(VERT_COLOR)
  41.   struct colorvector *pvcolor;
  42. #ifndef FUNCTION_CALLS
  43. #ifdef WIN32
  44.   void (APIENTRY *glColorP)(const GLfloat *);
  45. #else
  46.   void (*glColorP)(const GLfloat *);
  47. #endif
  48. #endif /* ifndef FUNCTION_CALLS */
  49. #endif 
  50.  
  51. #ifdef TEXTURE
  52.   struct vector *ptexture;
  53. #ifndef FUNCTION_CALLS
  54. #ifdef WIN32
  55.   void (APIENTRY *glTexCoord2fvP)(const GLfloat *);
  56. #else
  57.   void (*glTexCoord2fvP)(const GLfloat *);
  58. #endif
  59. #endif  /* ifndef FUNCTION_CALLS */
  60. #endif 
  61.  
  62. #ifndef FUNCTION_CALLS
  63. #ifdef  TEXTURE
  64.   glTexCoord2fvP = glTexCoord2fv;
  65. #endif
  66. #if defined(FACET_COLOR) || defined(VERT_COLOR)
  67.   glColorP = tb->ColorP;
  68. #endif
  69. #if defined(FACET_NORM) || defined(VERT_NORM)
  70.   glNormal3fvP = glNormal3fv;
  71. #endif
  72.   glVertex3fvP = glVertex3fv;
  73. #endif  
  74.  
  75.  
  76.         for(meshnum=meshcount-1;meshnum>=0;meshnum--) {
  77.         numverts = pmsh[meshnum].numverts;
  78.         pvert = pmsh[meshnum].verts;
  79. #if defined(FACET_NORM) || defined(VERT_NORM)
  80.       pnorm = pmsh[meshnum].norms;
  81. #endif
  82. #if defined(FACET_COLOR) || defined(VERT_COLOR)
  83.       pvcolor = pmsh[meshnum].vcolor;
  84. #endif
  85. #ifdef TEXTURE
  86.       ptexture = pmsh[meshnum].texture;
  87. #endif
  88. #ifdef EXTERNAL
  89.       lExternfunc(capability);
  90. #endif
  91. #if   defined(FACET_COLOR) && !defined(FUNCTION_CALLS)
  92.       (*glColorP)((const GLfloat *) (pvcolor));
  93. #elif defined(FACET_COLOR) &&  defined(FUNCTION_CALLS) && !defined(COLOR4)
  94.       glColor3fv((const GLfloat *) (pvcolor));
  95. #elif defined(FACET_COLOR) &&  defined(FUNCTION_CALLS) &&  defined(COLOR4)
  96.       glColor4fv((const GLfloat *) (pvcolor));
  97. #endif
  98. #if    defined(FACET_NORM) && !defined(FUNCTION_CALLS)
  99.       (*glNormal3fvP)((const GLfloat *) (pnorm));
  100. #elif  defined(FACET_NORM) &&  defined(FUNCTION_CALLS) 
  101.       glNormal3fv((const GLfloat *) (pnorm));
  102. #endif
  103.       glBegin(mode);
  104.  
  105. #ifdef BY_TWO
  106.                 for(vertnum=numverts-2;vertnum>=0;vertnum--) {
  107. #else
  108.                 for(vertnum=numverts-1;vertnum>=0;vertnum--) {
  109. #endif
  110.  
  111. #if   defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  112.       (*glColorP)((const GLfloat *) (pvcolor));
  113. #elif defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) && !defined(COLOR4)
  114.       glColor3fv((const GLfloat *) (pvcolor));
  115. #elif defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) &&  defined(COLOR4)
  116.       glColor4fv((const GLfloat *) (pvcolor));
  117. #endif
  118. #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)
  119.       (*glTexCoord2fvP)((const GLfloat *) (ptexture));
  120. #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS)
  121.       glTexCoord2fv((const GLfloat *) (ptexture));
  122. #endif
  123. #if    defined(VERT_NORM) && !defined(FUNCTION_CALLS)
  124.       (*glNormal3fvP)((const GLfloat *) (pnorm));
  125. #elif  defined(VERT_NORM) &&  defined(FUNCTION_CALLS)
  126.       glNormal3fv((const GLfloat *) (pnorm));
  127. #endif
  128. #ifdef FUNCTION_CALLS
  129.       glVertex3fv((const GLfloat *) (pvert));
  130. #else 
  131.       (*glVertex3fvP)((const GLfloat *) (pvert));
  132. #endif
  133.  
  134.  
  135. #ifdef BY_TWO
  136.   #if    defined(VERT_COLOR) && !defined(FUNCTION_CALLS)
  137.                     (*glColorP)((const GLfloat *) (pvcolor+1));
  138.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) && !defined(COLOR4)
  139.                     glColor3fv((const GLfloat *) (pvcolor+1));
  140.   #elif  defined(VERT_COLOR) &&  defined(FUNCTION_CALLS) &&  defined(COLOR4)
  141.                     glColor4fv((const GLfloat *) (pvcolor+1));
  142.   #endif
  143.   #if    defined(TEXTURE) && !defined(FUNCTION_CALLS)
  144.                         (*glTexCoord2fvP)((const GLfloat *) (ptexture+1));
  145.   #elif  defined(TEXTURE) &&  defined(FUNCTION_CALLS)
  146.                         glTexCoord2fv((const GLfloat *) (ptexture+1));
  147.   #endif
  148.   #if    defined(VERT_NORM) && !defined(FUNCTION_CALLS)
  149.                         (*glNormal3fvP)((const GLfloat *) (pnorm+1));
  150.   #elif  defined(VERT_NORM) &&  defined(FUNCTION_CALLS)
  151.                         glNormal3fv((const GLfloat *) (pnorm+1));
  152.   #endif
  153.   #ifdef FUNCTION_CALLS
  154.                         glVertex3fv((const GLfloat *) (pvert+1));
  155.   #else
  156.                         (*glVertex3fvP)((const GLfloat *) (pvert+1));
  157.   #endif
  158. #endif
  159.  
  160. #ifdef VERT_COLOR
  161.       pvcolor += 1;
  162. #endif
  163. #ifdef TEXTURE
  164.       ptexture += 1;
  165. #endif
  166. #ifdef VERT_NORM
  167.       pnorm += 1;
  168. #endif
  169.       pvert += 1;
  170.  
  171.     }
  172.       glEnd();
  173.     }
  174. }
  175.   
  176.